package cn.zn.modules.budget.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BudgetMoneyVO {
    private String id;
    /**
     * 计划金额
     */
    private Double totalMoney;
    /**
     * 冻结金额
     */
    private Double freezsMoney;
    /**
     * 支付金额
     */
    private Double useMoney;

    /**
     * 可用金额
     *
     * @return
     */
    public Double availableMoney() {
        return new BigDecimal(
                (totalMoney != null ? totalMoney : 0) -
                        (freezsMoney != null ? freezsMoney : 0) -
                        (useMoney != null ? useMoney : 0)).setScale(2, RoundingMode.HALF_UP).doubleValue();
    }
}
